﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using Gencode.PrsCommon.App;

namespace Gencode.PrsCommon.ControlData.GridControl
{
	/// <summary>
	/// DO NOT REMOVE THIS CLASS
	/// PlanGridGenerator is used in PrsWeb
	/// This class can't be removed before PrsWeb is not changed
	/// </summary>
    [System.Obsolete("Use Gencode.PrsCommon.Data.Plan.SaldoTable",false)]
	public class PlanSaldoGrid
	{
		public DataTable Table
		{
			get;
			set;
		}

		public void AddItem(int prsID, int planID, int abteilungID)
		{
			if (Table == null)
				InitTable();

			DataView dv = Gencode.PrsCommon.Data.Plan.PlanData.GetSaldo(prsID, abteilungID, planID);

			double soll = Util.RoundDouble(double.Parse(dv[0].Row["soll"].ToString()));
			double haben = Util.RoundDouble(double.Parse(dv[0].Row["haben"].ToString()));
			double vortrag = Util.RoundDouble(double.Parse(dv[0].Row["vortrag"].ToString()));

			DataRow row = Table.NewRow();
			row["Vortr"] = vortrag;
			row["Soll"] = soll;
			row["Haben"] = haben;
			row["Diff"] = Util.RoundDouble(vortrag + (haben - soll));
			Table.Rows.Add(row);
		}

		public void AddItem()
		{
			if (Table == null)
				InitTable();

			DataRow row = Table.NewRow();
			row["Vortr"] = "";
			row["Soll"] = "";
			row["Haben"] = "";
			row["Diff"] = "";
			Table.Rows.Add(row);
		}

		public void InitTable()
		{
			Table = new DataTable();
			Table.Columns.Add("Vortr", typeof(string));
			Table.Columns.Add("Soll", typeof(string));
			Table.Columns.Add("Haben", typeof(string));
			Table.Columns.Add("Diff", typeof(string));
		}
	}
}
